package com.zc.im.service.user.impl;

import com.zc.im.mapper.user.ZcOwnWorkMapper;
import com.zc.im.model.user.ZcOwnWork;
import com.zc.im.model.user.ZcOwnWorkExample;
import com.zc.im.model.user.ZcOwnWorkKey;
import com.zc.im.service.user.ZcOwnWorkService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by wangcc on 2017/8/1.
 */
@Service
public class ZcOwnWorkServiceImpl implements ZcOwnWorkService {

    private Logger logger = Logger.getLogger(ZcOwnWorkServiceImpl.class);

    @Autowired
    private ZcOwnWorkMapper zcOwnWorkMapper;

    @Override
    public ZcOwnWork findZcOwnWork(Integer zcOwnWorkId) {
        ZcOwnWork zcOwnWork = null;
        if (zcOwnWorkId == null) {
            logger.error("find ZcOwnWork is null");
        }
        ZcOwnWorkExample example = new ZcOwnWorkExample();
        ZcOwnWorkExample.Criteria criteria = example.createCriteria();
        criteria.andUidEqualTo(zcOwnWorkId);
        try {
         List<ZcOwnWork> listzcOwnWork = zcOwnWorkMapper.selectByExample(example);
         if (listzcOwnWork == null || listzcOwnWork.size()==0) {
             return zcOwnWork;
         }
            zcOwnWork = listzcOwnWork.get(0);
        }catch (Exception e) {
            logger.error(e.getMessage(),e);
        }
        return zcOwnWork;
    }
}
